import React from 'react';
import { Space } from 'antd';

interface ToolbarButtonProps {
  icon: React.ReactElement;
  text: string;
  onClick?: Function;
}

export const ToolbarButton: React.FC<ToolbarButtonProps> = ({
  icon,
  text,
  onClick,
}) => {
  const handleClick = () => {
    if (onClick instanceof Function) {
      onClick();
    }
  };

  return (
    <span onClick={handleClick}>
      <Space>
        {icon}
        {text}
      </Space>
    </span>
  );
};
